package com.neutech.demo.day02;

import java.util.Scanner;

public class DemoHomeWork01 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        while (true){
            System.out.println("请输入你的工资来判断你最后到手的工资");
            double salary = input.nextDouble();
            double lastSalary =  insurance(salary);
            System.out.println("你的到手工资为: " + lastSalary);
        }
    }
    public static  double insurance(double salary){
        double endowmentInsurance = 0;//养老保险
        double medicalInsurance = 0;//医疗保险
        double unemploymentIinsurance = 0;//失业保险
        double employment_injury_insurance = 0;//工伤保险
        double maternity_insurance = 0;//生育保险
        double housing_Provident_Fund = 0;//住房公积金
        double five_insurances_and_one_fund = 0;//五险一金
        double individual_income_tax = 0;//个人所得税

        endowmentInsurance = salary * (8.0/100);
        medicalInsurance = salary * (2.0/100) + 3;
        unemploymentIinsurance = salary * (1.0/100);
        employment_injury_insurance = salary * (0.5/100);
        maternity_insurance = salary * (1.0/100);
        housing_Provident_Fund = salary * (12.0/100);
        five_insurances_and_one_fund = endowmentInsurance + medicalInsurance + unemploymentIinsurance
                 + employment_injury_insurance + maternity_insurance + housing_Provident_Fund + five_insurances_and_one_fund;
        double deduction_of_five_insurances_and_one_fund = 0;//扣除五险一金到手的钱
        deduction_of_five_insurances_and_one_fund = salary - five_insurances_and_one_fund;
        double start_insurance = salary- 5000-five_insurances_and_one_fund;//要扣税的工资
        if (salary <= 5000){
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + 0);
            return  deduction_of_five_insurances_and_one_fund;
        }else if (salary >5000 && salary <= 8000){
            individual_income_tax = start_insurance * (3.0/100);
            salary =  deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }else if (salary > 8000 && salary <=17000){
            individual_income_tax = start_insurance * (10.0/100);
            salary = deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }else if (salary >17000 && salary <=30000){
            individual_income_tax = start_insurance * (20.0/100);
            salary = deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }else if (salary > 30000 && salary <=40000){
            individual_income_tax = start_insurance * (25.0/100);
            salary = deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }else if (salary >40000 && salary <=60000){
            individual_income_tax = start_insurance * (30.0/100);
            salary = deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }else if (salary >60000 && salary <=85000){
            individual_income_tax = start_insurance * (35.0/100);
            salary = deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }else {
            individual_income_tax = start_insurance * (45.0/100);
            salary = deduction_of_five_insurances_and_one_fund - individual_income_tax;
            System.out.println("五险一金为：" + five_insurances_and_one_fund);
            System.out.println("个人所得税为：" + individual_income_tax);
            return salary;
        }

    }

}
